package com.woniuxy.controller;

import com.woniuxy.util.MinioUtil;
import io.minio.errors.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.Map;

/**
 * @Classname UploadController
 * @Description TODO
 * @Date 2025/8/18 11:22
 * @Created by pc
 */
@RestController
@RequestMapping("/upload")
public class UploadController {
    @Resource
    private MinioUtil minioUtil;

    @PostMapping
    public Map<String,Object> upload(MultipartFile file) throws RegionConflictException, InvalidBucketNameException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
        Map<String, Object> map = minioUtil.updateFile(file, "data");
        return map;
    }
}
